Batteries are always used as backup power supply means in electronic devices such as a data storage device. For data storage devices, data security is particularly important. Therefore, in the case of power off, a battery has to provide sufficient power to at least store data into a non-volatile memory or hard disk. It is possible for the battery to fall or to have an insufficient power. Therefore, electronic devices such as a data storage device need to periodically test batteries to obtain information such as whether the batteries have a failure and whether the power is sufficient.